﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using HgRemoteContracts;

namespace HgRemoteServer.Config
{
	public class Repository : ConfigurationElement
	{
		[ConfigurationProperty("Name", IsKey = true)]
		public string Name
		{
			get { return this["Name"] as string; }
			set { this["Name"] = value; }
		}

		[ConfigurationProperty("RootPath")]
		public string RootPath
		{
			get { return this["RootPath"] as string; }
			set { this["RootPath"] = value; }
		}

		[ConfigurationProperty("Tasks")]
		public RepositoryTaskCollection Tasks
		{
			get { return this["Tasks"] as RepositoryTaskCollection; }
			set { this["Tasks"] = value; }
		}

		internal HgRepo ToWcfRepo()
		{
			return new HgRepo()
			{
				Name = this.Name,
				Tasks = this.Tasks.Select(t => t.ToWcfTask()).ToList()
			};
		}
	}
}
